package sql.db;

import sql.exception.*;

public class CompOperand 
{
	private int type;
	private String value = null;
	private String tableName = null;
	private String colName = null;
	
	public CompOperand(String value) {
		super();
		setType(Main.COMP_VALUE);
		setValue(value);
	}
	
	public CompOperand(String tableName, String colName) {
		super();
		setType(Main.COMP_COL);
		setTableName(tableName);
		setColName(colName);
	}
	
//////////////////////////////////////////////////////////////////////////
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public String getValue(Tuple tuple) throws MyDBException {
		if (type == Main.COMP_VALUE)
			return value;
		
		return tuple.getValueByTableCol(tableName, colName);
	}
	public void setValue(String value) {
		this.value = value;
	}
	public String getTableName() {
		return tableName;
	}
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}
	public String getColName() {
		return colName;
	}
	public void setColName(String colName) {
		this.colName = colName;
	}
	
	
}
